package com.xxonehjh.demo.spring.core;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

@Configuration
public class AppConfig {

	/**
	 * 使用静态方法，那样可以早于 AppConfig 实例化； 不然会迫使 AppConfig 过早实例化
	 * 
	 * 如果非静态方法，Spring会出现下列告警信息
	 * @Bean method AppConfig.propertyPlaceholderConfigurer is non-static and 
	 * returns an object assignable to Spring's BeanFactoryPostProcessor interface. 
	 * This will result in a failure to process annotations 
	 * such as @Autowired, @Resource and @PostConstruct within the method's 
	 * declaring @Configuration class. 
	 * Add the 'static' modifier to this method to avoid these container 
	 * lifecycle issues; see @Bean javadoc for complete details.
	 *
	 * @author huangjh
	 * @date 2021-7-26 17:30:45
	 * @return
	 */
	@Bean
	public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
		return new PropertySourcesPlaceholderConfigurer();
	}
}